home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Atari Compendium
/
The Atari Compendium (Toad Computers) (1994).iso
/
files
/
umich
/
music
/
eked-m1.zoo
/
src
/
eked-m1.c
< prev
next >
Wrap
C/C++ Source or Header
|
1995-02-19
|
6KB
|
270 lines
/*
* EKED-M1 : Editor for Korg M1 synth; eked-m1.c : start-up and menu code
* Copyright (C) 1995 Steven M. Eker (Steven.Eker@brunel.ac.uk)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <stddef.h>
#include <stdio.h>
#include <gemfast.h>
#include <aesbind.h>
#include <vdibind.h>
#include "gm/gem_man.h"
#include "eked-m1.h"
#include "defs.h"
#include "types.h"
#include "externs.h"
#define RSC_FILE "eked-m1.rsc"
#define RSC_ERR 1
OBJECT *name_form;
int shared_handle;
static OBJECT *menu;
static OBJECT *information;
static void gem_init();
static void gem_exit();
static int do_menu(int title, int item);
static int mono_hack(OBJECT *obj);
static void value_opt();
int main()
{
gem_init();
ic_window();
ic_newbank();
do{
wm_monitor(menu, &do_menu);
}while(fm_alert(2, QUIT_ALERT) != 1);
gem_exit();
return 0;
}
static void gem_init()
{
gm_init();
if(!rm_load(RSC_FILE)){
form_alert(1, "[1][Can't find resouce file!][ QUIT ]");
gm_exit();
exit(RSC_ERR);
}
if(nr_planes == 1)
rm_map_all(&mono_hack);
shared_handle = gm_opnvwk();
rm_gaddr(R_TREE, NAME_FORM, &name_form);
wm_init();
ic_init();
pe_init();
rm_gaddr(R_TREE, MENU, &menu);
rm_gaddr(R_TREE, INFORMATION, &information);
menu_bar(menu, TRUE);
km_scan_menu(menu);
graf_mouse(ARROW, 0L);
}
static void gem_exit()
{
menu_bar(menu, FALSE);
pe_exit();
ic_exit();
wm_exit();
rm_free();
gm_clsvwk(shared_handle);
gm_exit();
}
static int do_menu(int title, int item)
{
switch(item){
case M_INFO:
(void) fm_dialog(information, 0, (OBJECT *) NULL, 0);
break;
case M_QUIT:
return R_QUIT;
case M_VIRT_KBD:
vk_window();
break;
case M_MSND_LIST:
ms_window();
break;
case M_DRUM_LIST:
ds_window();
break;
case M_OPEN:
case M_SAVE_AS:
case M_SAVE:
case M_PRINT:
case M_COPY:
case M_FLIP:
case M_ERASE:
case M_TRANSMIT:
case M_RECEIVE:
case M_COMB_LIST:
case M_PROG_LIST:
case M_GLOB_EDIT:
ic_bankop(item);
break;
case M_NEW:
ic_newbank();
break;
case M_MIDI:
midi_opt();
break;
case M_VALUES:
value_opt();
break;
case M_DIALOGS:
ic_dialogs();
break;
case M_CYCLE:
wm_cycle();
break;
}
return 0;
}
void mn_bank_sel()
{
menu[M_OPEN].ob_state &= ~DISABLED;
menu[M_SAVE_AS].ob_state &= ~DISABLED;
menu[M_SAVE].ob_state &= ~DISABLED;
menu[M_PRINT].ob_state &= ~DISABLED;
menu[M_COPY].ob_state &= ~DISABLED;
menu[M_FLIP].ob_state &= ~DISABLED;
menu[M_ERASE].ob_state &= ~DISABLED;
menu[M_TRANSMIT].ob_state &= ~DISABLED;
menu[M_RECEIVE].ob_state &= ~DISABLED;
menu[M_COMB_LIST].ob_state &= ~DISABLED;
menu[M_PROG_LIST].ob_state &= ~DISABLED;
menu[M_GLOB_EDIT].ob_state &= ~DISABLED;
}
void mn_bank_desel()
{
menu[M_OPEN].ob_state |= DISABLED;
menu[M_SAVE_AS].ob_state |= DISABLED;
menu[M_SAVE].ob_state |= DISABLED;
menu[M_PRINT].ob_state |= DISABLED;
menu[M_COPY].ob_state |= DISABLED;
menu[M_FLIP].ob_state |= DISABLED;
menu[M_ERASE].ob_state |= DISABLED;
menu[M_TRANSMIT].ob_state |= DISABLED;
menu[M_RECEIVE].ob_state |= DISABLED;
menu[M_COMB_LIST].ob_state |= DISABLED;
menu[M_PROG_LIST].ob_state |= DISABLED;
menu[M_GLOB_EDIT].ob_state |= DISABLED;
}
static int mono_hack(OBJECT *obj)
{
if(obj->ob_type == G_BOX && (obj->ob_spec & 0x70) == 0x40)
obj->ob_spec ^= 0x60; /* change pattern 4 to pattern 2 */
return 0; /* only examine root of each object tree */
}
static void value_opt()
{
static int point_size = 8;
OBJECT *value_options;
int roll_mode, size, t;
roll_mode = gm_roll_mode(-1);
rm_gaddr(R_TREE, VALUE_OPTIONS, &value_options);
GM_SELECT(roll_mode == R_ROLL, value_options, V_ROLL);
GM_SELECT(roll_mode == R_RIGHTUP, value_options, V_RIGHTUP);
GM_SELECT(roll_mode == R_LEFTUP, value_options, V_LEFTUP);
size = point_size;
unum_update(value_options + V_SIZE, size);
fm_begin_dialog(value_options, 0);
do{
t = fm_run_dialog();
switch(t){
case V_SIZE:
size = fm_roll(value_options, t, size, 8, 20, &unum_update);
break;
}
}while(t != V_OK && t != V_CANCEL);
fm_end_dialog();
if(t == V_CANCEL)
return;
if(value_options[V_ROLL].ob_state & SELECTED)
roll_mode = R_ROLL;
else if(value_options[V_RIGHTUP].ob_state & SELECTED)
roll_mode = R_RIGHTUP;
else
roll_mode = R_LEFTUP;
gm_roll_mode(roll_mode);
if(size != point_size){
ls_size(size);
ms_size(size);
point_size = size;
}
}
/*
* Copy string, padding it out to n characters with spaces
* or trucating it to n characters as neccessary.
* Terminate with zero as (n+1)th character.
*/
char *strfcpy(char *d, char *s, size_t n)
{
for(; n > 0 && *s; n--)
*d++ = *s++;
for(; n > 0; n--)
*d++ = ' ';
*d = '\0';
return d;
}
/*
* Copy n characters, converting zeros to spaces.
* Terminate with zero as (n+1)th character.
*/
char *korg2str(char *d, char *s, size_t n)
{
for(; n > 0; s++, n--)
*d++ = *s ? *s : ' ';
*d = '\0';
return d;
}
/*
* Copy string, padding it out to n characters with spaces
* or trucating it to n characters as neccessary.
* No terminating zero.
*/
char *str2korg(char *d, char *s, size_t n)
{
for(; n > 0 && *s; n--)
*d++ = *s++;
for(; n > 0; n--)
*d++ = ' ';
return d;
}
int iszero(char *s, size_t n)
{
for(; n > 0; n--){
if(*s++)
return FALSE;
}
return TRUE;
}